package com.hspedu.method;

/**
 * @author DL5O
 * @version 1.0
 */
public class ThreadMethodExercise {
    public static void main(String[] args) throws InterruptedException {
        T01 t01 = new T01();
        for (int i = 1; i <= 10; i++) {
            System.out.println("hi " + i);
            if (i == 5) {
                Thread thread = new Thread(t01);
                thread.start();
                thread.join();
                System.out.println("子线程结束...");
            }
            Thread.sleep(1000);
        }
        System.out.println("主线程结束...");
    }
}

class T01 implements Runnable{

    @Override
    public void run() {

        for (int i = 1; i <= 10 ; i++) {
            System.out.println("hello " + i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

